<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let hero = {
            name: "吕布",
            level: 18,
            skill: function (age) {
                console.log(age + '天崩地裂');
            }

        }
        //1. 获取对象属性的两种方式
        // 对象名.属性名
        //对象名[字符串]  字符串是属性名
        console.log(hero.name); // 吕布
        console.log(hero['level']); // 18

        //2. 变量是window的属性
        var age = 22;

        // 3. window 一般省略
        console.log(age); // 22
        console.log(window.age); //22

        //4. 对象方法的调用
        hero.skill(); //undefind
        hero.skill(12); //12 天崩地裂


        function eat() {
            console.log('吃火锅');

        }
        eat();//吃火锅
        window.eat(); //吃火锅


        //5. 对象可以动态地添加属性和方法
        hero.address = '艾泽';
        hero.paly = function () {
            console.log('王者');
        }
        console.log(hero);//吕布 18 艾泽  f f
        hero.paly();

        // 6. 属性的修改(变量的重新赋值)
        hero.name = "貂蝉";
        console.log(hero);

        //7. 属性的删除 delete 对象名。属性名

        delete hero.name;
        console.log(hero);



    </script>
</body>

</html>